﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example35.aspx.cs" Inherits="Chapter05.Example35" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 5-35 检查属性是否为 null 或 undefined</title>
</head>
<body>
    <form>
        <div>
            <script type="text/javascript">
                var myData = {
                    name: "Adam",
                    city: null,
                };

                if (!myData.name) {
                    document.writeln("name is null or undefined");
                } else {
                    document.writeln("name is not null or undefined");
                }

                if (!myData.city) {
                    document.writeln("city is null or undefined");
                } else {
                    document.writeln("city is not null or undefined");
                }
            </script>
        </div>
    </form>
</body>
</html>
